/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.softace.jdbc.annotations;

import com.softace.jdbc.MySqlJdbcUtilities;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * This annotation is used over fields or bean properties/attributes that needed
 * to be get from the database.
 *
 * @see JdbcEntity
 *
 * @author s1lent_warrior
 */
@Documented
@Target(value = ElementType.FIELD)
@Retention(value = RetentionPolicy.RUNTIME)
public @interface JdbcAttribute {

    /**
     * The name of the column in the database for the particular attribute.
     *
     * @return Column name in the database
     */
    public String columnName();

    /**
     * The name of the table for the particular attribute. This field is
     * optional and defaults to the {@link JdbcEntity#tableName} unless
     * specified.
     *
     * @return Table name for the particular attribute
     * @see JdbcEntity
     */
    public String tableName() default "";

    /**
     * Specifies weather this attribute is a key for the Map. <br>This field is
     * required in order to call
     * {@link MySqlJdbcUtilities#getObjectsAsMapFromResultSet} and
     * {@link MySqlJdbcUtilities#getObjectsAsMapFromQuery} methods. Otherwise
     * these methods would throw No Key Found Exception!
     *
     * @return {@code true} if this attribute is a key else {@code false}
     *
     * @see MySqlJdbcUtilities#getObjectsAsMapFromQuery(java.lang.String,
     * java.lang.Class, java.lang.Object...)
     * @see MySqlJdbcUtilities#getObjectsAsMapFromResultSet(java.sql.ResultSet,
     * java.lang.Class)
     */
    public boolean isKeyForMap() default false;
}
